<template>
  <div>
    <header>
      <van-icon name="arrow-left" @click="back" />
      <span>我的关注</span>
      <div></div>
    </header>
    <div style="height:11vw"></div>

    <main>
      <div v-for="(item, index) in list" :key="index" class="teacher" v-show="!show">
        <img :src="item.avatar" alt />
        <div>
          <h4>
            {{item.teacher_name}}
            <span
              style="margin-left: 1.6vw;font-size: .29333rem;font-size: 2.93333vw;color: #ea7a2f;"
            >{{item.level_name}}</span>
          </h4>
          <p>{{item.introduction}}</p>
        </div>
        <button @click="qx(item.collect_id)">取消关注</button>
      </div>
      <p v-show="!show" style="margin-top:20px;text-align:center;color:gray">没有更多了...</p>
      <h3 v-show="show" style="text-align:center;margin-top:30px">暂无关注</h3>
    </main>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  data() {
    return {};
  },
  computed: {
    list: function () {
      return this.$store.state.attention.list;
    },
    show: function () {
      return this.$store.state.attention.show;
    },
   
  },
  created() {},
  methods: {
    back() {
      window.history.back();
    },
    //取消关注
    qx(id) {
      this.$store.dispatch("Qxattention", id);
      Toast.loading({
        message: "加载中...",
        forbidClick: true,
      });
      setTimeout(() => {
        window.location.reload();
      }, 500);
    },
  },
  mounted() {
    this.$store.dispatch("GETattention");

  },
};
</script>

<style lang="scss" scoped>
header {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: #fff;
  font-size: 4vw;
  top: 0;
  height: 11.73333vw;
  box-sizing: border-box;
  position: fixed;
  z-index: 9;
  background: #fff;
  border-bottom: 1px solid #f0f2f5;
  span {
    width: 70%;
    text-align: center;
  }
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  .teacher {
    width: 90%;
    height: 18vw;
    background: #fff;
    padding: 10px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-radius: 1.33333vw;
    display: flex;
    align-items: center;
    margin: 0 auto;
    margin-top: 30px;
    img {
      width: 10.66667vw;
      height: 10.66667vw;
    }
    p {
      font-size: 3.2vw;
      color: #b7b7b7;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      width: 53.33333vw;
    }
    button {
      font-size: 3.46667vw;
      color: #eb6100;
      text-align: center;
      width: 20.26667vw;
      height: 7.46667vw;
      line-height: 7.46667vw;
      background: rgba(235, 97, 0, 0.1);
      border-radius: 4.13333vw;
      border: none;
    }
  }
}
</style>